package com.yuan.zs.bean;

import android.os.Parcel;
import android.os.Parcelable;

import com.alibaba.fastjson.JSON;

import org.xutils.db.annotation.Column;
import org.xutils.db.annotation.Table;

import java.util.Date;

/**
 * 通告
 */
@Table(name = "t_notice")
public class Notice implements Parcelable {

	@Column(name = "id", isId = true, autoGen = false)
	private int id;
	@Column(name = "type")
	private int type; // 通告的类型：0课程，1菜单，2致家长书 等
	@Column(name = "title")
	private String title; // 标题
	@Column(name = "content")
	private String content; // 内容
	@Column(name = "pics")
	private String pics; // 图片组
	@Column(name = "publishDate")
	private Date publishDate; // 发布时间
	@Column(name = "targetParents")
	private String targetParents; // 目标家长（手机号，以英文逗号“,”分隔）
	@Column(name = "targetChannels")
	private String targetChannels; // 目标群组（以英文逗号“,”分隔）
	@Column(name = "targetGrades")
	private String targetGrades;// 目标班级（以英文逗号“,”分隔）
	@Column(name = "publisher")
	private String publisher; // 发布者用户名
	@Column(name = "schoolId")
	private int schoolId; // 学校

	public String[] getPicsList() {
		return JSON.parseObject(pics, String[].class);
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getPics() {
		return pics;
	}

	public void setPics(String pics) {
		this.pics = pics;
	}

	public Date getPublishDate() {
		return publishDate;
	}

	public void setPublishDate(Date publishDate) {
		this.publishDate = publishDate;
	}

	public String getTargetParents() {
		return targetParents;
	}

	public void setTargetParents(String targetParents) {
		this.targetParents = targetParents;
	}

	public String getTargetChannels() {
		return targetChannels;
	}

	public void setTargetChannels(String targetChannels) {
		this.targetChannels = targetChannels;
	}

	public String getTargetGrades() {
		return targetGrades;
	}

	public void setTargetGrades(String targetGrades) {
		this.targetGrades = targetGrades;
	}

	public String getPublisher() {
		return publisher;
	}

	public void setPublisher(String publisher) {
		this.publisher = publisher;
	}

	public int getSchoolId() {
		return schoolId;
	}

	public void setSchoolId(int schoolId) {
		this.schoolId = schoolId;
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(this.id);
		dest.writeInt(this.type);
		dest.writeString(this.title);
		dest.writeString(this.content);
		dest.writeString(this.pics);
		dest.writeLong(this.publishDate != null ? this.publishDate.getTime() : -1);
		dest.writeString(this.targetParents);
		dest.writeString(this.targetChannels);
		dest.writeString(this.targetGrades);
		dest.writeString(this.publisher);
		dest.writeInt(this.schoolId);
	}

	public Notice() {
	}

	protected Notice(Parcel in) {
		this.id = in.readInt();
		this.type = in.readInt();
		this.title = in.readString();
		this.content = in.readString();
		this.pics = in.readString();
		long tmpPublishDate = in.readLong();
		this.publishDate = tmpPublishDate == -1 ? null : new Date(tmpPublishDate);
		this.targetParents = in.readString();
		this.targetChannels = in.readString();
		this.targetGrades = in.readString();
		this.publisher = in.readString();
		this.schoolId = in.readInt();
	}

	public static final Creator<Notice> CREATOR = new Creator<Notice>() {
		@Override
		public Notice createFromParcel(Parcel source) {
			return new Notice(source);
		}

		@Override
		public Notice[] newArray(int size) {
			return new Notice[size];
		}
	};
}
